package com.nettest.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.ToStringStyle;

import com.nettest.entity.BaseAuditable;

public class TreeVo implements Serializable {
    private static final long serialVersionUID = -594131865481252531L;

    private String id;
    private String text;
    private String iconCls;
    private Attribute attributes;
    private String state = "closed";
    private List<TreeVo> children = new ArrayList<TreeVo>();

    public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getIconCls() {
		return iconCls;
	}

	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}

	public Attribute getAttributes() {
		return attributes;
	}

	public void setAttributes(String url) {
		this.attributes = new Attribute(url);
	}

	public List<TreeVo> getChildren() {
		return children;
	}

	public void setChildren(List<TreeVo> children) {
		this.children = children;
	}
	protected class Attribute {
    	private String url;

    	public Attribute(String url) {
    		this.url = url;
		}
		public String getUrl() {
			return url;
		}

		public void setUrl(String url) {
			this.url = url;
		}
    }
    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if(!(obj instanceof BaseAuditable))
			return false;
		BaseAuditable other = (BaseAuditable) obj;
		if (this.getId() == null) {
			if (other.getId() != null)
				return false;
		} else if (!this.getId().equals(other.getId()))
			return false;
		return true;
	}
    @Override
    public String toString() {
        return org.apache.commons.lang.builder.ReflectionToStringBuilder
                .toString(this, ToStringStyle.MULTI_LINE_STYLE);
    }
}
